<div class="page animated bounceInDown">



<Widget:show title="云文件" col="12">
<Widget:action id="modelObj-action" title="">
    <a grid-btn grid-delete class="btn disabled btn-danger btn-sm" href="{$delUrl}">删除</a>
</Widget:action>
<div class="table-responsive">
    <table id="modelObj" class="table table-bordered table-striped table-hover">
        <thead>
            <th w_render="fileUrl">文件名</th>
            <th w_index="type">文件类型</th>
            <th w_index="size">文件大小</th>
        </thead>
    </table>
</div>
<div id="modelObj-pager" class="widget-footer"></div>
</Widget:show>

<include file="table" url="0" table="modelObj" rows="10" />


<Widget:show cls="upload" title="文件上传" col="12">
<input multiple="true" id="inputFile" name="file" type="file" class="file-loading">
</Widget:show>

</div>

<script type="text/javascript">
$(function(){
    $("#inputFile").fileinput({
        uploadUrl: "http://d.apicloud.com/mcm/api/file", 
        showUpload:false,
        uploadExtraData:{
            type:'image/jpeg',
        },
        ajaxSettings:{
            headers:{
                "Accept":"*/*",
                "X-APICloud-AppId":"{$Think.session.app_id}",
                "X-APICloud-AppKey":"{$Think.session.appKey}",
            }
        }
    });

    $('#inputFile').on('fileuploaded', function(event, data, previewId, index) {
        modelObj.refreshPage();
    });

})

function fileUrl(record, rowIndex, colIndex, options) {
    var name = modelObj.getRecordIndexValue(record, 'name');
    var url = modelObj.getRecordIndexValue(record, 'url');

    return '<a target="_blank" href="'+url+'" >'+name+'</a>';
} 
   
</script>
